package com.google.gwt.sample.dynatablerf.server;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
import com.google.web.bindery.requestfactory.shared.Locator;

public abstract class AbstractEntityLocator<T, G> extends Locator<T, G> {

	private ApplicationContext context;

	public AbstractEntityLocator() {
		super();
		HttpServletRequest request = RequestFactoryServlet
				.getThreadLocalRequest();
		ServletContext servletContext = request.getSession()
				.getServletContext();
		context = WebApplicationContextUtils
				.getWebApplicationContext(servletContext);
	}

	protected ApplicationContext getContext() {

		return context;
	}
}
